﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Microsoft.Xna.Framework;
using Microsoft.Xna.Framework.Graphics;
using Microsoft.Xna.Framework.Input;
using Trippy.Animation;
using Trippy.Abilities;
using Trippy.CollidableGameComponents;
using Trippy.CollidableGameComponents.Objects;
using Trippy.Levels;

namespace Trippy.CollidableGameComponents.Agents
{
    public class Cat : Agent
    {
        public static Texture2D SpriteSheet { get; private set; }

        public Ian Master { get; set; }

        protected override void LoadContent()
        {
            if (SpriteSheet == null) SpriteSheet = CurrentLevel.Game.Content.Load<Texture2D>("Sprites/Agents/bird_sheet");
            Sprite = new AnimatedSprite(this, SpriteSheet, 96, 96, 0, 0, 0, 0, 1, 0f);
            base.LoadContent();
        }

        public override void Draw(GameTime gameTime)
        {
            StandardDraw(gameTime);
            base.Draw(gameTime);
        }

        public Cat(Level level)
            : base(level)
        {
        }


        public override void Update(GameTime gameTime)
        {
            float elapsedTime = TrippyUtilities.CalculateElapsedTime(gameTime);

            Vector2 swoop = CurrentLevel.Hero.Position - Position;

            UpdateStandardPhysics(elapsedTime);

            base.Update(gameTime);
        }


        protected override void CollisionHandler(CollidableGameComponent component, CollidableGameComponent.CollisionSide side)
        {
            if (component is Hero)
            {
                Hero h = (Hero)component;
                switch (side)
                {
                    case CollisionSide.Top:
                        h.Bounce(BoundingBox.Top);
                        break;
                    case CollisionSide.Right:
                        h.HitRightWall(BoundingBox.Right);
                        break;
                    case CollisionSide.Bottom:
                        h.Die(Hero.MannerOfDeath.Enemy);
                        break;
                    case CollisionSide.Left:
                        h.HitLeftWall(BoundingBox.Left);
                        break;
                    default:
                        throw new ArgumentOutOfRangeException("side");
                }
            }

            base.CollisionHandler(component, side);
        }

    }
}
